<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<meta name="viewport"  content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
	<title>发布动态</title>
	<link rel="stylesheet" href="css/publish.css" />
</head>
<body class="body">
<form action="insertComm" method="post" enctype="multipart/form-data">
	<div class="nav1">
		<a href="dong"><img src="img/尖括号.png" width="22px"/></a>
		<button class="button button1" id="button" style="">发表</button>
	</div>
	<input type="hidden" value="${user.userId}" name="userId"/>
	<textarea placeholder="这一刻的想法..." class="context" name="commContent"></textarea>
	<div id="tutu">
		<div id="clic" style="margin-left: 20px;position: relative;">
			<img src="img/tianjia.png" id="tjimg"  style="max-width:374px;display: none;"/>
			<br/>
			<img src="img/tianjia.png" id="" style="max-width:374px;"/>
			<input type="file" name="commImg" multiple="multiple" style="position: absolute; top: 0; bottom: 0; left: 0;right: 0; opacity: 0;" accept="img/jpeg,img/png,img/gif"
				   class="uploadImg"   id="file">

		</div>
	</div>
	<div class="xiaxia">
		<p><img src="img/位置 (1).png" width="24px"/>&nbsp;&nbsp;所在位置<span><img src="img/尖括号右.png" width="20px"></span></p>
		<p><strong style="font-size: 21px;">@</strong>&nbsp;&nbsp;提醒谁看<span><img src="img/尖括号右.png" width="20px"></span></p>
		<p><img src="img/人.png" width="24px"/>&nbsp;&nbsp;谁可以看<span>公开&nbsp;<img src="img/尖括号右.png" width="20px"></span></p>
	</div>
</form>




<script type="text/javascript" src="js/jquery-3.2.1.js" ></script>
<script>
	$(".context").keyup(function(e)
	{
		var text =  $(".context").val(),
				len = text.length;
		if(len == 0)
		{
			$("#button").removeClass('button');
			$("#button").addClass('button1');
		}
		else
		{
			$("#button").removeClass('button1');
			$("#button").addClass('button');
		}
	});

	$("#tutu").change(function () {
		var input=$("#file");
		var flie=input[0].files[0];//获取input上传的文件

		if(!flie.name){
			alert("未选择图片");
		}else{
			//浏览器对文件上传路径进行安全处理，无法直接获取input的value进行访问，故转化为获取图片路径的url进行安全访问
			var url=window.URL.createObjectURL(flie);//将上传文件转化为url
			if (url!=null||url!=""){
				$("#tjimg").show();
				$("#tjimg").attr('src',url);//更新img的src属性
			}
		}
	})
</script>
</body>
</html>
